<template>
	<div class="newHome">
		<InfoList :data="data" :number="pageSize" v-on:Upnumber="upSize($event)" v-on:refresh="refresh()"></InfoList>
		<div class="pagination">
		    <el-pagination
		      @size-change="handleSizeChange"
		      @current-change="handleCurrentChange"
		      :current-page="currentPage4"
		      :page-sizes="[30, 50, 80, 100]"
		      :page-size="pageSize"
		      layout="total, sizes, prev, pager, next, jumper"
		      :total="total">
		    </el-pagination>
		  </div>
	</div>
</template>

<script >
	import ArgList from 'components/Home/ArgList'
	import InfoList from './InfoList'
	export default{
		name:'newHome',
		components:{InfoList},
		props: ['exit','id'],
	  data(){
	    return{
	      currentPage4: 1,
	      data:[],
	      total:0,
	      pageNum:1,//第几页
	      pageSize:30//条数
	    }
	  },
	  mounted(){
	    this.getMore()
	  },
	  methods:{
			upSize(e){
					this.pageSize = e
					this.getMore()
			},
			refresh(){
				this.getMore()
			},
	    handleSizeChange(val) {
				this.pageSize = val
				this.getMore()
	    },
	    handleCurrentChange(val){
	    	this.pageNum = val
	      this.getMore()
	    },
	    getMore:function(){
	    	this.$store.commit('LoadingTrue');
	        this.$http.post('/vrv-monitor-platform-web/module/queryMore',{
	          id:this.$route.params.id,
	          pageNum:this.pageNum,
	          pageSize:this.pageSize
	        }).then(res=>{
	          this.$store.commit('Loadingfalse');
	          this.total = res.body.total>3000?3000:res.body.total
	          this.data = res.body.data
	          this.data.forEach((value,index)=>{
							this.$set(value,'readText', 0 )
							this.$set(value,'checked', false )
							this.$set(value,'collectName', '加入收藏' )
							if (localStorage.read) {
										let _readArr = localStorage.read
										let readArr = JSON.parse(_readArr);
										if(readArr.indexOf(value.data[0].id)!=-1){
											this.$set(value,'isread', true )
										}else{
											this.$set(value,'isread', false )
										}
								}else{
									this.$set(value,'isread', false )
								}
								let flag = typeof(value.title)!='undefined'
                let imgurl = flag==true?value.domain:value.data[0].domain
								if(flag){
									if(value.collected==false||value.collected=='false'){
										this.$set(value,'enshrine', false )
									}else{
										this.$set(value,'enshrine', true )
									}
								}else{
									if(value.data[0].collected==false||value.data[0].collected=='false'){
										this.$set(value,'enshrine', false )
									}else{
										this.$set(value,'enshrine', true )
									}
								}
								this.$http.get(`static/${imgurl}.png`).then(res=>{
									this.$set(value,'urlimg', `url(static/${imgurl}.png)` )
								}).catch(err=>{
									this.$set(value,'urlimg',"url('static/defult.png')")
								})
						})
	        })
	      }
	    },
	}
</script>
<style type="text/css" scoped>
	.newHome{
		background: #fff;
		min-height: 100%;
		margin-right: 1.8rem;
	}
	.pagination{
		text-align: right;
		padding: 0.93rem 0.93rem;
	}
</style>